#include "widget.h"
#include "ui_widget.h"
#include <QPainter>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::paintEvent(QPaintEvent *event)
{
    (void)event;
    QPainter painter(this);
    // 首先绘制一个圆
    QPen pen;
    pen.setColor(Qt::red);
    pen.setStyle(Qt::DashLine);
    pen.setWidth(5);
    painter.setPen(pen);

    // 定义画刷，填充到圆里
    QBrush brush;
    // 设置画刷填充的颜色
    brush.setColor(Qt::green);
    // 设置画刷填充的样式，默认是没有样式的
    // brush.setStyle(Qt::SolidPattern);
    // brush.setStyle(Qt::Dense1Pattern);
    brush.setStyle(Qt::Dense2Pattern);
    painter.setBrush(brush);

    painter.drawEllipse(100,100,100,100);
}

